// eslint-disable-next-line no-unused-vars
import React from 'react'
import { Notification } from '@alifd/next'

window.openNotification = ({ key, type, title, duration }) => {
  switch (type) {
    case 'loading':
      title = title + '...'
      duration = duration || 1000 * 60 * 3
      break
    case 'success':
      title = title + '成功！'
      duration = duration || 1000 * 3
      break
    case 'error':
      title = title + '出错！'
      duration = duration || 1000 * 3
      break
    case 'warning':
      duration = duration || 1000 * 3
      break
    case 'help':
      duration = duration || 1000 * 3
      break
    default:
      duration = duration || 1000 * 3
      break
  }
  if (key) Notification.close(key)
  Notification.config({ placement: 'br' })
  Notification.open({
    key,
    type: type === 'loading' ? 'success' : type,
    title,
    icon: type,
    maxCount: 0,
    duration,
    onClick: () => {
      console.log('Notification Clicked!')
    }
  })
}
